#! /bin/sh
# display velocity scans and "picks"

set -v

WIDTH=300
HEIGHT=400
WIDTHOFF1=0
WIDTHOFF2=315
WIDTHOFF3=630
WIDTHOFF4=945
HEIGHTOFF1=500

# Look at velocity scans -- in reality would make picks interactively,
# using, e.g., the mpicks option of xcontour nc=15 fc=.4  to create the par.$cdp files.
nv=120
dv=75.0
fv=4000.0
fold=12  # only have 12 shots, otherwise would be 64/2=32 for dsx=dgx
nout=501 # ns
dxout=0.004

cdp=1500
suwind <modeldata key=cdp min=$cdp max=$cdp |
suvelan nv=$nv dv=$dv fv=$fv |
suxcontour nc=15 fc=.4  bclip=0.5 wclip=0.0 f2=$fv d2=$dv \
	label1="Time (sec)" label2="Velocity (ft/sec)" \
	title="Velocity Scan for CMP $cdp" \
	windowtitle="V-Scan: $cdp" legend=1 units="semblance" \
	cmap=default \
	wbox=$WIDTH hbox=$HEIGHT xbox=$WIDTHOFF1 ybox=$HEIGHTOFF1 &
sed <par.$cdp '
	s/tnmo/xin/
	s/vnmo/yin/
' >unisam1.p
unisam nout=$nout fxout=0.0 dxout=$dxout \
	par=unisam1.p method=linear |
xgraph n=$nout nplot=1 d1=$dxout f1=0.0 \
	label1="Time (sec)" label2="Velocity (ft/sec)" \
	title="Velocity: CMP $cdp" \
	windowtitle="Profile: $cdp" \
	linecolor=2 style=seismic \
	-geometry ${WIDTH}x${HEIGHT}+${WIDTHOFF2}+${HEIGHTOFF1} &

cdp=2000
suwind <modeldata key=cdp min=$cdp max=$cdp count=$fold |
suvelan nv=$nv dv=$dv fv=$fv |
suxcontour nc=15 fc=.4  bclip=0.5 wclip=0.0 f2=$fv d2=$dv \
	label1="Time (sec)" label2="Velocity (ft/sec)" \
	title="Velocity Scan for CMP $cdp" \
	windowtitle="V-Scan: $cdp" legend=1 units="semblance" \
	cmap=default \
	wbox=$WIDTH hbox=$HEIGHT xbox=$WIDTHOFF3 ybox=$HEIGHTOFF1 &
sed <par.$cdp '
	s/tnmo/xin/
	s/vnmo/yin/
' >unisam2.p
unisam nout=$nout fxout=0.0 dxout=$dxout \
	par=unisam2.p method=linear |
xgraph n=$nout nplot=1 d1=$dxout f1=0.0 \
	label1="Time (sec)" label2="Velocity (ft/sec)" \
	title="Velocity: CMP $cdp" \
	windowtitle="Profile: $cdp" \
	linecolor=2 style=seismic \
	-geometry ${WIDTH}x${HEIGHT}+${WIDTHOFF4}+${HEIGHTOFF1} &

cdp=2500 # don't plot this one
#suwind <modeldata key=cdp min=$cdp max=$cdp count=$fold |
#suvelan nv=$nv dv=$dv fv=$fv |
#suxcontour nc=15 fc=.4  bclip=0.5 wclip=0.0 f2=$fv d2=$dv \
#	label1="Time (sec)" label2="Velocity (ft/sec)" \
#	title="Velocity Scan for CMP $cdp" \
#	cmap=default \
#	wbox=$WIDTH hbox=$HEIGHT xbox=$WIDTHOFF2 ybox=$HEIGHTOFF &
sed <par.$cdp '
	s/tnmo/xin/
	s/vnmo/yin/
' >unisam3.p
#unisam nout=$nout fxout=0.0 dxout=$dxout \
#	par=unisam3.p method=linear |
#xgraph n=$nout nplot=1 d1=$dxout f1=0.0 \
#	label1="Time (sec)" label2="Velocity (ft/sec)" \
#	title="Stacking Velocity Function: CMP $cdp" \
#	linecolor=2 style=seismic \
#	-geometry ${WIDTH}x${HEIGHT}+${WIDTHOFF3}+${HEIGHTOFF} &

cdp=3000 # don't plot this one either
#suwind <modeldata key=cdp min=$cdp max=$cdp count=$fold |
#suvelan nv=$nv dv=$dv fv=$fv |
#suxcontour nc=15 fc=.4  bclip=0.5 wclip=0.0 f2=$fv d2=$dv \
#	label1="Time (sec)" label2="Velocity (ft/sec)" \
#	title="Velocity Scan for CMP $cdp" \
#	cmap=default \
#	wbox=$WIDTH hbox=$HEIGHT xbox=$WIDTHOFF4 ybox=$HEIGHTOFF &
sed <par.$cdp '
	s/tnmo/xin/
	s/vnmo/yin/
' >unisam4.p
#unisam nout=$nout fxout=0.0 dxout=$dxout \
#	par=unisam4.p method=linear |
#xgraph n=$nout nplot=1 d1=$dxout f1=0.0 \
#	label1="Time (sec)" label2="Velocity (ft/sec)" \
#	title="Stacking Velocity Function: CMP $cdp" \
#	linecolor=2 style=seismic \
#	-geometry ${WIDTH}x${HEIGHT}+${WIDTHOFF5}+${HEIGHTOFF} &


# Create parameter file from "picks" for sunmo
echo  "cdp=" | tr -d "\012" >stkvel.p
for cdp in 1500 2000 2500
do
	echo  "$cdp," | tr -d "\012" >>stkvel.p
done


echo 3000 >>stkvel.p

for cdp in 1500 2000 2500 3000
do
	cat <par.$cdp >>stkvel.p
done

exit
